﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Besture.Bll;
using Besture.Common;
using Besture.Model;

namespace Besture.UI.Portal.FindUserPwd
{
    public partial class FindUserPwdList3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitData();
            }
        }

        /// <summary>
        /// 初始化数据
        /// </summary>
        private void InitData()
        {
            UserBaseModel userBaseModel = new UserBaseDac().GetModel(Convert.ToInt32(EncryptHelper.Decrypt(StringHelper.Query("user"))));
            lblPhone.Text = userBaseModel.Phone.Replace(userBaseModel.Phone.Substring(3, 4), "****");
        }

        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSub_Click(object sender, EventArgs e)
        {
            UserBaseDac userBaseDac = new UserBaseDac();
            UserBaseModel userBaseModel = userBaseDac.GetModel(Convert.ToInt32(EncryptHelper.Decrypt(StringHelper.Query("user"))));
            userBaseModel.LoginPwd = StringHelper.GetMD5(txtPass.Value);
            userBaseModel.UpdateBy = userBaseModel.ID;
            userBaseModel.UpdateTime = DateTime.Now;
            userBaseDac.Update(userBaseModel);
            Response.Redirect(@"\Portal\UserCenter\Login.aspx");
        }
    }
}